import http from '../utils/http.js'

//查询优惠券表格
function showCoupon() {
    return http({
        method: 'post',
        url: '/admin/couponInfo/selectAllCouponsByPage',
        params: {
            limit: 1000,
            page: 1
        }
    }).then((req) => {
        console.log(req)
        return req
    }).catch((err) => {
        return err
    })
}

//查询优惠券中的商品选择表格
function showGoods() {
    return http({
        method: 'post',
        url: '/admin/content/showContentByPage',
        params: {
            limit: 1000,
            page: 1
        }
    }).then((req) => {
        return req
    }).catch((err) => {
        return err
    })
}

//优惠券查询界面
function QueryCoupon(obj) {
    return http({
        method: 'post',
        url: '/admin/couponInfo/selectCouponInfoByCondition',
        params: {
            limit:1,
            page:10000,
            ...obj,
        }
    }).then((req)=>{
        console.log("查询接口",req)
        return req
    })
}

//优惠券添加界面
function AddCoupon(obj) {
    return http({
        method: 'post',
        url: '/admin/couponInfo/addCoupon',
        params:{
            ...obj,
            usageTime:"2020-10-11 12:00:00",
            expirationTime:"2020-10-11 12:00:00"
        }
    })
}

//优惠券管理编辑界面
function EditCoupon(obj) {
    console.log({...obj})
    return http({
        method: 'post',
        url: '/admin/couponInfo/updateCouponsById',
        params: {
            ...obj,
            usageTime:"2020-10-11 12:00:00"
        }
    })
}

//优惠券管理删除
function DelCoupon(id) {
    return http({
        method: 'post',
        url: '/admin/couponInfo/deleteCouponById',
        params: {id},
    }).then((req) => {
        return req
    }).catch((err) => {
        return err
    })
}


export {
    showCoupon,
    showGoods,
    QueryCoupon,
    AddCoupon,
    EditCoupon,
    DelCoupon
}